
// const API = ['/', '/login', '/signin', '/api/list', '/api/login', '/api/signin', '/api/logout'];

// module.exports = (req, res, next) => {
//     let user = req.session.user;
//     if(!!user){
//         res.cookie("name", user.name, { maxAge: 1000 * 60 * 60, httpOnly: true });
//     }
//     if (API.indexOf(req.url) > -1 || !!user) {
//         next();
//     } else if (!user) {
//         res.send({ code: 5000, message: '登录失效，请重新登录！' })
//     }
// }

module.exports = (req, res, next) => {
    let user = req.session.user;
    if (!!user) {
        next();
    } else {
        res.redirect('/')
    }
}